package mirrormonkey.core.tools.applications;

import mirrormonkey.core.server.ServerCoreModule;
import mirrormonkey.framework.ServerSyncAppState;

import com.jme3.app.SimpleApplication;
import com.jme3.network.Network;
import com.jme3.network.Server;
import com.jme3.system.JmeContext;

public class ServerTestApplication extends SimpleApplication {

	public final Server server;

	public final ServerSyncAppState appState;

	public final ServerCoreModule coreModule;

	public ServerTestApplication() throws Exception {
		server = Network.createServer(10024);
		appState = new ServerSyncAppState(server);
		coreModule = appState.getModule(ServerCoreModule.class);
	}

	@Override
	public void start() {
		server.start();
		start(JmeContext.Type.Headless);
	}

	@Override
	public void stop() {
		server.close();
		super.stop(true);
	}

	@Override
	public void simpleInitApp() {
		getStateManager().attach(appState);
	}

}